/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [NovelBookRebate.java]
 * Creation Date        [24-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_principles.ocp.example01;

/**
 * 折扣类小说
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class NovelBookRebate extends NovelBook {

	public NovelBookRebate(String name, double price, String author) {
		super(name, price, author);
	}

	/**
	 * 通过重写getPrice()方法, 扩展实现了新增加的打折业务
	 * 
	 * @return
	 */
	@Override
	public double getPrice() {
		double originalPrice = super.getPrice();
		double discountPrice = 0;
		if (originalPrice > 4000) { // 原价大于40元, 则打9折
			discountPrice = originalPrice * 90 / 100;
		} else {
			discountPrice = originalPrice * 80 / 100;
		}
		return discountPrice;
	}
}
